<?php
namespace app\admin\controller;

use think\Controller;
class Login extends Controller
{
    public function index()
    {
       return view();
    }
    /**
     * 系统登录处理
     */
    public function login()
    {
        $params = request()->param();

        $validate = new \app\common\validate\Admin();
        if (true !== $validate->scene('login')->check($params)) {
            return json(['state' => 0, 'msg' => $validate->getError()]);
        }

        //记住账号
        $rptAutoLogin = $this->request->post('rptAutoLogin');
        if ($rptAutoLogin == "true") {
            cookie("rptAutoLogin", $params['account']);
        }
        return (new \app\common\model\Admin())->login($params);
    }
    /**
     * 退出
     */
    public function logout()
    {
        session(null, 'admin');
        $this->redirect('Login/index');
    }
 
}
